package binarytree;


import java.util.Map;
import java.util.TreeMap;


public class   Demo {
    public static void main(String[] args) {
        Map<Stu,String> map = new TreeMap<>((a,b)->{
            return a.age-b.age;
        });

        Stu stu = new Stu("yyy",88);
        Stu stu2 = new Stu("ttt",23);
        Stu stu3 = new Stu("jjj",88);
        map.put(stu, "shuaige");
        map.put(stu2, "meinv");
        map.put(stu3, "dalao");


        System.out.println(map.get(stu));

    }
}

class Stu implements Comparable<Stu>{
    int age ;
    String name;

    public Stu( String name,  int age) {
        this.age = age;
        this.name = name;
    }

    @Override
    public int compareTo(Stu o) {
        return this.age-o.age;
    }
}




